using System.ComponentModel;
using Mistral.ComponentModel;
using Mistral.Interface;
using Mistral.Interface.Features;
using Mistral.Options;

namespace Mistral.Plugin
{
	public class OptionView : ITreeNodeDescriptor
	{
		readonly IOption _option;

		public OptionView( IOption option )
		{
			_option = option;
		}
			
		#region IGetPropertyGridView Members

		public object GetPropertyGridView()
		{
			VirtualObject view = new VirtualObject();
			
			CustomProperty property = new CustomProperty();
			property.Name = _option.Name;
			//property.PropertyType = _option.GetSerializationType( );
			property.Description = _option.Description;
			property.Category = _option.Category.Name;
			property.ConverterType = typeof(ExpandableObjectConverter);
			property.ValueProvider = new ValueProvider_Simple( _option );

			view.AddProperty( property );
			return view;
		}

		#endregion

		#region ITreeNodeDescriptor Members

		public string Name
		{
			get { return _option.Name; }
		}

		public object Tag
		{
			get { return _option; }
		}

		public System.Collections.IEnumerable Children
		{
			get { return null; }
		}

		#endregion
	}
}
